package com.cn.aam.checaiduo.ui.product.fragment;

import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.cn.aam.checaiduo.R;
import com.cn.aam.checaiduo.base.BaseFragment;
import com.cn.aam.checaiduo.base.adapter.BaseRecycerAdapter;
import com.cn.aam.checaiduo.base.adapter.layoutmanager.FullyGridLayoutManager;
import com.cn.aam.checaiduo.bean.brandsquence.BrandDataB;
import com.cn.aam.checaiduo.bean.brandsquence.SequenceDataB;
import com.cn.aam.checaiduo.ui.product.adapter.BrandTestAdapter;
import com.cn.aam.checaiduo.ui.product.adapter.SequenceTestAdapter;
import com.cn.aam.checaiduo.utils.MyEditTextUtils;

import java.io.Serializable;
import java.util.List;

import butterknife.BindView;


/**
 * @author 微木森林
 * @time 2017/7/21 下午1:39
 * @description 搜索默认列表-品牌
 * @remark
 */
public class BrandListFragment extends BaseFragment {


    @BindView(R.id.recy_simple)
    RecyclerView recySimple;


    private BrandTestAdapter brandAdapter;


    public static BrandListFragment newInstance() {
        BrandListFragment instance = new BrandListFragment();
        return instance;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.content_simple_recyclerview;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        recySimple.setLayoutManager(new FullyGridLayoutManager(mActivity, 1));
        recySimple.setItemAnimator(new DefaultItemAnimator());//设置Item增加、移除动画
        brandAdapter = new BrandTestAdapter(mActivity);
        recySimple.setAdapter(brandAdapter);
        brandAdapter.setOnItemClickListener(new BaseRecycerAdapter.OnItemClick() {
            @Override
            public void onClick(int position) {
                BrandDataB item = brandAdapter.getItem(position);
                if (itemClickListener!=null) itemClickListener.onClick(item);
            }
        });
    }

    public void addListData(List<BrandDataB> data) {
        brandAdapter.setDataToAdapter(data);
    }


    private ItemClickListener itemClickListener;

    public interface ItemClickListener {
        void onClick(BrandDataB item);
    }


    public void setItemClickListener(ItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }

}
